package IO;

import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class Duqu2 {
    public static void main(String[] args) throws IOException {
        //需求：通过字符流读取数据：按字符数组读取数据
        //创建字符输入流对象
        Reader reader=new FileReader("Libs/1.txt");
        char [] chs=new char[1024];
        int a;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < chs.length; i++) {
            if ((a = reader.read()) != -1) {
                chs[i] = (char)a;
                sb.append(chs[i] + " ");
            }
        }
        String str = sb.toString();
        System.out.println(str.trim());
        reader.close();

        /*
        //网上老师的方法
        Reader reader=new FileReader("Libs/1.txt");
        char [] chs=new char[3];
        int len;
        while ((len = reader.read(chs)) != -1) {
            String s=new String(chs,0,len);
            System.out.println(s);
        }
        reader.close();
        */
    }
}
